import type { Router } from 'vue-router'

export default function setupTransitionGuard(router: Router) {
  router.afterEach((to, from) => {
    if ([to, from].every(({ meta: { step } }) => !isNaN(step as number))) {
      const toStep = to.meta.step as number
      const fromStep = from.meta.step as number
      to.meta.transition = toStep < fromStep ? 'slide-right' : 'slide-left'
    }
  })
}
